package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "护理等级管理")
@RestController
@RequestMapping("/nursingLevel")
public class NursingLevelController extends BaseController {
    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("listAll")
    @ApiOperation("查询全部护理等级")
    public ResponseResult<List<NursingLevelVo>> getAllLevel() {
        List<NursingLevelVo> list = nursingLevelService.queryLevelList();
        return success(list);
    }

//    @PostMapping("/insertBatch")
//    @ApiOperation(value = "批量插入护理等级信息")
//    public ResponseResult insertBatch(
//            @ApiParam(value = "护理等级数据列表", required = true)
//            @RequestBody List<NursingLevelDto> nursingLevelDtos) {
//        nursingLevelService.insertBatch(nursingLevelDtos);
//        return ResponseResult.success();
//    }

    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    public ResponseResult addNursingLevel(@ApiParam(value = "新增的护理等级对象", required = true) @RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.addNursingLevel(nursingLevelDto);
        return success();
    }

    @GetMapping("/listByPage")
    @ApiOperation(value = "条件查询护理等级列表", notes = "返回护理等级列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "integer", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "integer", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "护理等级名称", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态（0：禁用，1：启用）", dataType = "integer", paramType = "query")
    })
    public ResponseResult<PageResponse> selectByPage(Integer pageNum, Integer pageSize, String name, Integer status) {
        return success(nursingLevelService.selectByPage(pageNum, pageSize, name, status));
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理等级")
    public ResponseResult<NursingProjectVo> selectById(@ApiParam(value = "护理项目对象的id", required = true) @PathVariable Long id) {
        NursingLevelVo nursingLevelVo = nursingLevelService.selectById(id);
        return success(nursingLevelVo);
    }

    @PutMapping("/update")
    @ApiOperation(value = "根据id修改护理等级信息")
    public ResponseResult updateNursingLevel(@ApiParam(value = "修改的护理等级对象", required = true) @RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.updateNursingLevel(nursingLevelDto);
        return success();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "根据id删除护理等级信息")
    public ResponseResult deleteById(@ApiParam(value = "护理等级对象的id", required = true) @PathVariable Long id) {
        nursingLevelService.deleteById(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "更新护理等级状态")
    public ResponseResult updateStatus(@ApiParam(value = "护理等级对象的id", required = true) @PathVariable Long id,
                                       @ApiParam(value = "状态（0：禁用，1：启用）", required = true) @PathVariable Integer status) {
        nursingLevelService.updateStatus(id, status);
        return success();
    }

}
